home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7925 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: acsu.buffalo.edu!usenet
  2. From: nvp@acsu.buffalo.edu
  3. Newsgroups: comp.lang.c++
  4. Subject: Interpreting tokens in C++???
  5. Date: Wed, 14 Feb 1996 14:31:45 -0500
  6. Organization: SUNY@Buffalo
  7. Message-ID: <312238A1.4F70@cadman.cit.buffalo.edu>
  8. NNTP-Posting-Host: armstrong.cs.buffalo.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. NNTP-Posting-User: nvp
  13. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  14.  
  15. Hello, I am trying to write C++ code that considers a theoretical
  16. language (TLAN), and through two classes (and re-casting), interprets
  17. tokens from the TLAN to have meaning in C++.
  18.  
  19. BTW, these programs are not being compiled (no error checking for now),
  20. but are interpreted by the code.
  21.  
  22. Here's a sample TLAN program:
  23.  
  24. BEGIN // ignored by interpreter.
  25. SET I 10 // i = 10
  26. SET V 1  // v = 1
  27. WHILE V
  28.     BEGIN
  29.     INC V // v++
  30.         DEC I // i--
  31.         PRINT V // cout << v
  32. NEWLINE // endl
  33. END
  34. END // program end
  35.  
  36. I am presently using #define to define each token (using an integer)
  37. and strtok (from the c-library token.h).
  38.  
  39. For a statement like SET I 10, how would I get token I to = token 10?
  40.  
  41. Strtok breaks them up into tokens, but I am having problems with
  42. interpreting the meaning of statements after that ...
  43.  
  44. Thank you
  45.  
  46. Sincerely,
  47.  
  48. Nathan V. Patwardhan
  49. nvp@cs.buffalo.edu
  50.